package com.cms.meeting.service;

import com.cms.meeting.entity.Department;
import com.cms.meeting.mapper.DepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepartmentService {

    @Autowired
    DepartmentMapper departmentMapper;
    public Department getDepId(Integer id) {
        return departmentMapper.getDepId(id);
    }

    public List<Department> getAllDeps(){
        return departmentMapper.getAllDeps();
    }

    public Integer adddepartment(String departmentname) {
        Department department = departmentMapper.getDeptByName(departmentname);
        if(department!=null){
            return -1;
        }
        return departmentMapper.adddepartment(departmentname);
    }

    public Integer deleteDep(Integer departmentid) {
        return departmentMapper.deleteDep(departmentid);
    }

    public Integer updatedep(Integer id, String name) {
        return departmentMapper.updatedep(id , name);
    }
}
